#!/bin/bash

p="
~/bin/
~/gcode/bin/
/usr/local/bin
/usr/bin
/bin
/usr/local/sbin
/usr/sbin
/sbin
"
PATH=`echo $p|sed 's/ /:/g'`
export PATH

uname=`uname`  # Linux, FreeBSD
if [ $uname = "Linux" ]; then
    alias ls='ls --color=tty'
elif [ $uname = "FreeBSD" ]; then
    alias ls='ls -G'
fi

alias ll="ls -altr"
export CVS_RSH=ssh
alias ls='ls --color=tty'

alias vi=vim
export HISTTIMEFORMAT="%F %T "
alias h=history

function snc()
{
  uname=$(uname)
  if [[ $uname == 'Darwin' ]]; then
    export proot='/Volumes/PCRUZER'
    export troot='/Volumes/TCRUZER'
    export p="$proot/CRUZER"
    export t="$troot/CRUZER"
    export pvol='/Users/smandal/Documents/CRUZER.vol'
    export tvol='/dev/rdisk2s2'
    truecrypt='/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt'
  else
    export p='/media/truecrypt1/CRUZER'
    export t='/media/truecrypt9/CRUZER'
    truecrypt='/usr/bin/truecrypt'
  fi
  export tid="mydata/OM/tiddly.html"

  (
    if [[ ! -d $p ]]; then
      cmd="$truecrypt -t -k '' --protect-hidden=no $pvol $proot"
      eval $cmd

      if [[ ! -d $p ]]; then
        echo "$p not found"
        exit
      fi
    fi
    if [[ ! -d $t ]]; then
      cmd="$truecrypt -t -k '' --protect-hidden=no $tvol $troot"
      eval $cmd
      if [[ ! -d $t ]]; then
        echo "$t not found"
        exit
      fi
    fi
    ~/gcode/bin/sync.2 $p $t | tee a.sh
  )
}


note()
{
  uname=$(uname)
  if [[ $uname == "Darwin" ]]; then
    truecrypt='/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt'
    volume1='/Users/smandal/Documents/CRUZER.VOL'
    mountpoint1='/Volumes/PCRUZER'
  elif [[ $uname == "Linux" ]]; then
    truecrypt='/usr/bin/truecrypt'
    volume1='/b/om/CRUZER.VOL'
    mountpoint1='/media/truecrypt1'
  fi
  tiddly="$mountpoint1/CRUZER/mydata/OM/tiddly.html"

  if [[ ! -f "$tiddly" ]]; then
      $truecrypt --text --slot=1 -k='' --protect-hidden='no' $volume1 $mountpoint1
  fi
  if [[ $uname == "Darwin" ]]; then
    open -a Firefox.app "$tiddly"
  elif [[ $uname == "Linux" ]]; then
    (/usr/bin/firefox "$tiddly" &)
  fi
}

um()
{
  uname=$(uname)
  if [[ $uname == "Darwin" ]]; then
    /Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt --text -d
  elif [[ $uname == "Linux" ]]; then
    truecrypt -t -d
  fi
}

function mnt()
{
# is it mounted?
(cd ~/h && df -kh .) | tail -1|grep ':'
if [[ $? == 0 ]]; then  # is mounted
  :
else
  dir=$(ssh smandal@svl-junos-d009.juniper.net 'df -kh . | tail -1')
  h=$(echo "$dir" | sed 's,^.* ,,; s,$,/smandal,')
  (cd ~/ && sshfs smandal@svl-junos-d009.juniper.net:$h h)
fi
}

function umnt()
{
fusermount -u ~/h
}

function slog () 
{ 
    svn log -q --stop-on-copy $* | grep '^r'
}

function rslog ()
{
export S='https://svl-svn.juniper.net/svn/junos-2009'

if [[ "$2" !=  '' ]]; then
  svn log -v -r $1 $2
else
  svn info >/dev/null 2>&1
  if [[ $? != 0 ]]; then  # Not in a sandbox
    svn log -v -r $1 $S
  else
    svn log -v -r $1 .
  fi
fi
}


alias vs0='vncserver -depth 24 -geometry 1024x768'
alias vs1='vncserver -depth 24 -geometry 1152x900'
alias vs10='vncserver -depth 24 -geometry 1920x1080'
alias vs2='vncserver -depth 24 -geometry 1280x800'
alias vs3='vncserver -depth 24 -geometry 1280x900'
alias vs5='vncserver -depth 24 -geometry 1280x1024'
alias vs6='vncserver -depth 24 -geometry 1420x830'
alias vs65='vncserver -depth 24 -geometry 1440x900'
alias vs7='vncserver -depth 24 -geometry 1670x956'
alias vs8='vncserver -depth 24 -geometry 1660x980'
alias vs9='vncserver -depth 24 -geometry 1680x1050'

